package io.renren.modules.generator.service.impl;

import io.renren.modules.generator.entity.*;
import io.renren.modules.generator.entity.vo.TTrainingVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import io.renren.common.utils.R;
import io.renren.modules.generator.entity.form.TrainingForm;
import io.renren.modules.generator.service.TTrainingObjectService;
import io.renren.modules.generator.service.TTrainingPeopleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.generator.dao.TTrainingDao;
import io.renren.modules.generator.service.TTrainingService;


@Service("tTrainingService")
public class TTrainingServiceImpl extends ServiceImpl<TTrainingDao, TTrainingEntity> implements TTrainingService {

    @Autowired
    private TTrainingDao trainingDao;
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<TTrainingEntity> page = this.page(
                new Query<TTrainingEntity>().getPage(params),
                new QueryWrapper<TTrainingEntity>()
        );

        return new PageUtils(page);
    }


    /**
     * 新增训练表
     */
    public int insertTTraining(TTrainingEntity trainingEntity){
        return trainingDao.insertTTraining(trainingEntity);
    }
    /**
     * 新增 训练科目  批量的
     */
    public int insertTTrainingObject(List<TTrainingObjectEntity> list){
        Integer maxTrainingId=trainingDao.getMaxTrainingId();
        System.out.println("最大训练ID:"+maxTrainingId);
        System.out.println("最大训练ID:"+maxTrainingId);
        for (TTrainingObjectEntity tTrainingObjectEntity:list) {
            tTrainingObjectEntity.setTiainingId(maxTrainingId);
        }
        return trainingDao.insertTTrainingObject(list);
    }
    /**
     * 新增 训练人员  批量的
     */
    public int insertTTrainingPeople(List<TTrainingPeopleEntity> listPeople){
        return trainingDao.insertTTrainingPeople(listPeople);
    }
    /**
     * 层级 下拉框
     */
    public List<TTrainingDictionaryEntity> getLevel(){
        return trainingDao.getLevel();
    }
    /**
     * 目的 下拉框
     */
    public List<TTrainingDictionaryEntity> getDatachment(){
        return trainingDao.getDatachment();
    }
    /**
     * 组织单位
     */
    public List<TTrainingDictionaryEntity> getPurpose(){
        return trainingDao.getPurpose();
    }
    /**
     * 类型
     */
    public List<TTrainingDictionaryEntity> getTrainType(){
        return trainingDao.getTrainType();
    }

    /**
     * 回显数据 训练信息
     */
    public TTrainingEntity getHxTTraining(Integer id){
        return trainingDao.getHxTTraining(id);
    }
    /**
     * 回显 训练科目
     */
    public List<TTrainingObjectEntity> getHxTTrainingObject(Integer id){
        return trainingDao.getHxTTrainingObject(id);
    }
    /**
     * 回显 训练人员
     */
    public List<TTrainingPeopleEntity> getTTrainingPeople(Integer id){
        return trainingDao.getTTrainingPeople(id);
    }
    /**
     * 删除 训练信息
     */
    public int delTTrainingEntity(Integer id){
        return trainingDao.delTTrainingEntity(id);
    }
    /**
     * 删除 训练科目
     */
    public int delTTrainingObjectEntity(Integer id){
        return trainingDao.delTTrainingObjectEntity(id);
    }
    /**
     * 删除 训练人员
     */
    public int delTTrainingPeopleEntity(Integer id){
        return trainingDao.delTTrainingPeopleEntity(id);
    }
    /**
     * 修改 训练人员
     */
    public int updateTTrainingEntity(TTrainingEntity trainingEntity){
        return trainingDao.updateTTrainingEntity(trainingEntity);
    }

    /**
     * 列表
     */
    public PageUtils selectTTraining(Map<String, Object> params){
        IPage<TTrainingEntity> page = new Query<TTrainingEntity>().getPage(params);
        List<TTrainingEntity> teople = trainingDao.selectTTraining(params);
        page.setRecords(teople);
        return new PageUtils(page);
    }

    /**
     * 导出
     */
   public List<TTrainingVo> DcTTraining(TTrainingEntity trainingEntity){
        return trainingDao.DcTTraining(trainingEntity);
    }

    public List<Map<String,Object>> DcTTrainingMap(TTrainingEntity trainingEntity){
        return trainingDao.DcTTrainingMap(trainingEntity);
    }

    /**
     * 训练首页
     */
    public List<TTrainingEntity> getSYtraining(TTrainingEntity trainingEntity){
        return trainingDao.getSYtraining(trainingEntity);
    }
    /**
     *训练首页 中队
     * @param trainingEntity
     * @return
     */
   public List<TTrainingEntity> getZdtraining(TTrainingEntity trainingEntity){
        return trainingDao.getZdtraining(trainingEntity);
    }
    /**
     *修改训练走这个  添加训练科目-
     */
   public int addTTrainingObject(TTrainingObjectEntity objectEntity){
        return trainingDao.addTTrainingObject(objectEntity);
    }
    /**
     *修改训练走这个  添加训练人员
     */
   public int addTTrainingPeople(TTrainingPeopleEntity peopleEntity){
       return trainingDao.addTTrainingPeople(peopleEntity);
    }

    /**
     * 训练头部 所有支队总计
     */
   public List<TTrainingEntity> totalTrainingDetachment(TTrainingEntity tTraining){
        return trainingDao.totalTrainingDetachment(tTraining);
    }
    /**
     * 训练头部 所有中队总计
     */
   public List<TTrainingEntity> totalTrainingSquadron(TTrainingEntity trainingEntity){
        return trainingDao.totalTrainingSquadron(trainingEntity);
    }
    /**
     * 修改合格率
     * @param tTraining
     * @return
     */
   public int updateQualificationrate(TTrainingEntity tTraining){
       return trainingDao.updateQualificationrate(tTraining);
    }
    /**
     * 头部汇总
     */
   public List<TTrainingEntity> headCount(TTrainingEntity trainingEntity){
        return trainingDao.headCount(trainingEntity);
    }


}